package com.imooc.miaosha.pojo;

public enum CodeMsg {
    // 通用错误码
    SUCCESS(0,"success"),
    SERVER_ERROR(500100,"服务端异常"),
    BIND_ERROR(500101,"参数校验异常: %s"),
    SESSION_ERROR(500210,"session不存在或已经失效"),

    PASSWORD_EMPTY(500211,"密码不能为空"),
    PASSWORD_ERROR(500212,"密码错误"),
    MOBILE_EMPTY(500213,"手机号不能为空"),
    MOBILE_ERROR(500214,"手机号格式错误"),
    MOBILE_NOT_EXIST(500215,"手机号不存在"),
    USER_NOT_LOGIN(500215,"用户未登录"),

    //商品模块5003xx

    //订单模块5004xx

    //秒杀模块5005xx
    STOCK_EMPTY(500500,"库存不足"),
    ORDER_REPEAT(500501,"订单已存在，不能重复秒杀"),

    ;


    private int code;
    private String message;

    CodeMsg(int code, String message) {
        this.code=code;
        this.message=message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public CodeMsg fillArgs(Object... args) {
        this.message = String.format(this.message,args);
        return this;
    }
}
